//
//  DDCAuthAPI.swift
//  MT
//
//  Created by ooops on 2019/7/18.
//  Copyright © 2019年 张强. All rights reserved.
//

import UIKit
import Foundation

/// 网络
import Moya
import DeviceKit
import SwiftyRSA
import Security

import Result

enum DDCAuthAPI {
    /// validate
    case audit(version: String)
    /// 举报
    case report(username: String)
    
}


// MARK: ------------------ Api 参数 ----------------------
extension DDCAuthAPI: MTTargetType {

    /// 请求头
    public var headers: [String : String]? {
        guard let accessToken = UserDefaults.MTUserCenter.token.storedString else { return nil }
        return ["Access-Token": accessToken]
    }
    
    /// 基路径
    public var baseURL: URL {
        return URL(string: AuthServerBaseUrl)!
    }
    
    /// 路径
    public var path: String {
        switch self {
        case .audit(_):
            return "/version/audit"
        case .report(_):
            return "/user/tip-off"
        }
    }
    
    /// 请求方法
    public var method: Moya.Method {
        return .post
    }
    
    /// 参数
    var params: [String: Any]? {
        
        switch self {
        case let .audit(version):
            return ["version" : version]
        case let .report(username):
            return ["userName" : username]
        }
        
    }
    
}
